//
//  HJNetworkErrorView.m
//  KaiChat
//
//  Created by lx on 2023/11/10.
//

#import "HJNetworkErrorView.h"
#import "HJButton.h"

@implementation HJNetworkErrorView

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
 
        UIImageView *iconImageView = [UIImageView addToView:self];
        iconImageView.image = [UIImage imageNamed:@"warn_icon"];
        [iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(15);
            make.centerY.offset(0);
            make.width.height.offset(20);
        }];
     
        UILabel *titleLabel = [UILabel lableWithSuperView:self font:UIFontMake(12) color:UIColor.tj_FF5100Color title:@"Network Exception Click to retry" textAlignment:NSTextAlignmentLeft];
        [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(iconImageView.mas_right).offset(10);
            make.centerY.offset(0);
        }];
        
        HJButton *refreshButton = [HJButton addToView:self];
        refreshButton.userInteractionEnabled = NO;
        [refreshButton setImage:[UIImage imageNamed:@"networkRefresh"] forState:UIControlStateNormal];
        [refreshButton addTarget:self action:@selector(didClickRefreshButton) forControlEvents:UIControlEventTouchUpInside];
        [refreshButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.inset(leftRightMargin);
            make.centerY.offset(0);
            make.width.height.offset(36);
        }];
        
        self.addCornerRadius(10);
        self.backgroundColor = UIColor.tj_FFF8F1Color;
    }
    return self;
}

- (void)didClickRefreshButton {
    
    
}

@end
